/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;
import bean_session.CompetencesLocal;
import javax.ejb.EJB;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Mamoune
 */
@ManagedBean(name="login")
@RequestScoped

public class loginBean {
    @EJB
    private CompetencesLocal competences;
    private String username;

    /** Creates a new instance of loginBeans */
    public loginBean() {
        ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
        HttpServletRequest request = (HttpServletRequest) ec.getRequest();
        setUsername(request.getParameter("username"));
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String doLogin() {
        ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
        HttpServletRequest request = (HttpServletRequest) ec.getRequest();
        String urlRetour = "";
        if (username.equals("modou@modou.com")) {
            urlRetour = "PERSONNELclient.jsp";
        }
        return urlRetour;
    }

    public String doLogout() {
        return "../index.xhtml";
    }
}
